<?php
namespace Home\Controller;

use Think\Controller;

class IndexController extends Controller
{
    public function index()
    {
//        layout(false);
        $p = empty($_GET['p']) ? 1 : $_GET['p'];
        $enroll = M('enrollinfo'); // 实例化User对象
        $res = $enroll->order('addtime desc')->page($p . ',5')->select();
        $count = $enroll->count();// 查询满足要求的总记录数

        $Page = new \Think\Page($count, 5);// 实例化分页类 传入总记录数和每页显示的记录数
        $Page->setConfig('prev', '<li class="waves-effect"><i class="material-icons">chevron_left</i></li>');
        $Page->setConfig('next', '<li class="waves-effect"><i class="material-icons">chevron_right</i></li>');
        $Page->setConfig('first', '<li class="waves-effect"><i class="material-icons">1</i></li>');
        $Page->setConfig('last', '<li class="waves-effect"><i class="material-icons">%TOTAL_PAGE%</i></li>');
        $Page->setConfig('theme', '%UP_PAGE% %FIRST% %LINK_PAGE% %DOWN_PAGE% %END%');
        $show = $Page->show();// 分页显示输出

        $this->assign("res", $res);// 赋值分页输出
        $this->assign('page', $show);
        $this->display(); // 输出模板
    }
}